import mine from "@/utils/http/mine";
import { AttrItem, AttrList, category1List, category2List,category3List } from "./model/categoryType";


// 获取1级分类
export const reqCategory1List = () => {
    return mine.get<any,category1List>(`/admin/product/getCategory1`)
}

// 获取2级分类
export const reqCategory2List = (category1Id:number) => {
    return mine.get<any,category2List>(`/admin/product/getCategory2/${category1Id}`)
}

// 获取3级分类
export const reqCategory3List = (category2Id:number) => {
    return mine.get<any,category3List>(`/admin/product/getCategory3/${category2Id}`)
}

// 获取当前分类的属性列表
export const reqGetAttrList = (category1Id:number,category2Id:number,category3Id:number) => {
    return mine.get<any,AttrList>(`/admin/product/attrInfoList/${category1Id}/${category2Id}/${category3Id}`)
}

// 增加或者更新属性
export const reqAddOrUpDate = (attrInfo:AttrItem) => {
    return mine.post<any,null>(`/admin/product/saveAttrInfo`,attrInfo)
}

// 删除当前属性
export const removeAttr = (attrId:number) => {
    return mine.delete<any,null>(`/admin/product/deleteAttr/${attrId}`)
}